package day5;

import java.util.Scanner;

import org.junit.Test;

// OOP: Object Oriented Programming
public class OOPDemo {

	@Test
	public void test1() {
		int num = 2;
		double d = 3.14;
		int[] array = new int[3];
		
		Scanner scanner = new Scanner(System.in);
		
		// 引用数据类型是可以new对象
		// Student是自定义的类型
		// student: 变量，对于new出来的也叫对象
		Student student1 = new Student();
		student1.id = 1;
		student1.name = "zhangsan";
		student1.age = 23;
		student1.gender = "男";
		
		System.out.println(student1.id);
		System.out.println(student1.name);
		student1.study();
		
		Student student2 = new Student();
		student2.id = 2;
		student2.name = "wangwu";
		student2.age = 24;
		student2.gender = "女";
		student2.study();
		
		Teacher teacher1 = new Teacher();
		teacher1.id = 1;
		teacher1.name = "张三";
		teacher1.age = 30;
		teacher1.salary = 8000;
		teacher1.teach();
		System.out.println(teacher1);
	}
	
	@Test
	public void test2() {
		Student stu = new Student();
//		stu.id = 1;
//		stu.name = "zhangsan";
//		stu.age = 123;
//		stu.gender = "男";
		stu.setId(1);
		stu.setName("zhansgan");
		stu.setAge(23);
		stu.setGender("男");
		
		String name = stu.getName();
		
		stu.study();
		String str = stu.getInfo();
		System.out.println(str);
		System.out.println(stu.getInfo());
		System.out.println(stu.toString());
		// 可以省略toString(),直接打印对象
		System.out.println(stu);
	}
	
	@Test
	public void test55() {
		// 给new出来对象的属性设置数据，有两种方式：
		// 1、通过set方法设置数据
		Student student1 = new Student();
		student1.setId(1);
		student1.setName("张三");
		student1.setAge(23);
		student1.setGender("女");
		
		// 2、new 有参构造方法时候直接传过来数据
		Student student2 = new Student(2, "lisi", 23, "男");
		System.out.println(student2);
	}
	
	@Test
	public void test11() {
		int num = 3;
		// 对于引用数据类型的变量，也叫对象
		String str = "hello";
		String str1 = new String("Hello Java");
		Teacher teacher = new Teacher();
		// 对象.属性
		teacher.id = 1;
		// 对象.方法();
		int age = teacher.getAge();
		System.out.println(age);
		String name = teacher.getName();// Alt+Shift+L
		System.out.println(name);
		double salary = teacher.getSalary();
		System.out.println(salary);
		int[] array = teacher.getArray();
		System.out.println(array);
	}
	
	
	@Test
	public void test44() {
		int[] array1 = new int[3];
		System.out.println(array1);// [I@6659c656
		System.out.println(array1[0]);
		System.out.println(array1[1]);
		System.out.println(array1[2]);
		
		boolean[] array2 = new boolean[3];
		System.out.println(array2[0]);
		System.out.println(array2[1]);
		System.out.println(array2[2]);
		
		Student[] array3 = new Student[3];
		System.out.println(array3[0]);
		System.out.println(array3[1]);
		System.out.println(array3[2]);
	}
	
	
	
}
